package com.boxing;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;

@WebServlet(name = "StuServlet", value = "/StuServlet")
public class StuServlet extends HttpServlet {

    @Override
    public void init(ServletConfig config) throws ServletException {
        super.init(config);
        String encode = config.getInitParameter("encode");
        System.out.println("StuServlet初始化时配置的参数 encode:" +encode);
        ServletContext servletContext = config.getServletContext();
        Object scKey = servletContext.getAttribute("scKey");
        System.out.println("StuServlet servletContext:" +servletContext
                +" 获取到sc中的scKey:" + scKey);
    }

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        ServletContext servletContext = request.getServletContext();
        Object scKey = servletContext.getAttribute("scKey");
        System.out.println("StuServlet servletContext:" +servletContext
                +" 获取到sc中的scKey:" + scKey);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }
}
